<template>
  <view class="natice">
    <NoticeItem
      v-for="item in list"
      :key="item.id"
      :item="item"
      @close="(id) => setFlag(id)"
    ></NoticeItem>
  </view>
</template>

<script setup>
import { ref } from 'vue'
import NoticeItem from './NoticeItem.vue'

const list = ref([
  {
    id: 1,
    title: '通知1',
    content: '通知内容',
    flag: true,
  },
])
const setFlag = (id) => {
  list.value = list.value.map((item) => {
    if (item.id === id) {
      item.flag = false
    }
    return item
  })
}
</script>

<style lang="scss" scoped>
.natice {
  padding: 10px;
}
</style>
